<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>关键词申请</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <!--引入本地的css样式-->
    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/admin.css" media="all">

</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户名称</label>
                    <div class="layui-input-block">
                        <input type="text" id="customer_name" name="customer_name" lay-verify="required" placeholder="输入客户名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" id="btn_search" data-type="reload">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>

            <div class="layui-form-item">
                <!--关键词-->
                <label class="layui-form-label">关键词</label>
                <div class="layui-input-inline">
                    <input type="text" name="kw_name" lay-verify="required" autocomplete="off" class="layui-input" id="kw_name" placeholder="">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务类别</label>
                <div class="layui-input-inline">
                    <select name="service_type" lay-filter="service_type" lay-verify="required">
                        <option value="">--请选择--</option>
                        <option value="上传苹果商城">上传苹果商城</option>
                        <option value="不上传苹果商城">不上传苹果商城</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务年限</label>
                <div class="layui-input-inline">
                    <select name="application_period" lay-verify="required">
                        <option value="">--请选择--</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <!--价格-->
                <label class="layui-form-label required">价格</label>
                <div class="layui-input-inline">
                    <input type="text" value="" name="kw_price" lay-verify="required|suanziId" autocomplete="off" class="layui-input">
                </div>

            </div>

            <!--确认提交-->
            <div class="layui-form-item layui-btn-container">
                <!--<input type="button" lay-submit="" lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" value="确认">-->
                <button style="" type="submit" class="layui-btn" lay-submit="" lay-filter="LAY-user-front-submit" id="LAY-user-back-submit">确认</button>
            </div>








        </div>

        <div class="layui-card-body">

            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">

                    <button class="layui-btn layuiadmin-btn-admin" lay-event="add" id="add_employee" data-type="add_employee">添加客户</button>
                </div>
            </script>

            <!--<script type="text/html" id="toolbarDemo">-->
            <!--<div style="padding-bottom: 10px;">-->
            <!--<button class="layui-btn layuiadmin-btn-admin" lay-event="batchdel">删除</button>-->
            <!--<button class="layui-btn layuiadmin-btn-admin" id="add_employee" data-type="add_employee">添加</button>-->
            <!--</div>-->
            <!--</script>-->
            <!--数据表格-->
            <table class="layui-hide" id="LAY-user-back-manage" lay-filter="LAY-user-back-manage"></table>

            <script type="text/html" id="customerStateTpl">
                {{#  if(d.state==1){ }}
                <span>启用</span>
                {{#  } else if(d.state==2){ }}
                <span>停用</span>
                {{#  } }}
            </script>
            <!--  <script type="text/html" id="statusTpl">
                {{#  if(d.status == 1){ }}
                <span>正常</span>
                {{#  } else if(d.status == 2){ }}
                <button type="button" class="layui-btn-xs layui-btn-disabled">冻结</button>
                {{#  } else if(d.status == 3){ }}
                <button type="button" class="layui-btn-xs layui-btn-danger">删除</button>
                {{#  } }}
              </script>-->

            <script type="text/html" id="buttonTpl">
                {{#  if(d.check == true){ }}
                <button class="layui-btn layui-btn-xs">已审核</button>
                {{#  } else { }}
                <button class="layui-btn layui-btn-primary layui-btn-xs">未审核</button>
                {{#  } }}
            </script>

            <script type="text/html" id="table-useradmin-admin">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                {{#  if(d.role == '超级管理员'){ }}
                <a class="layui-btn layui-btn-disabled layui-btn-xs"><i class="layui-icon layui-icon-delete"></i>删除</a>
                {{#  } else { }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                {{#  } }}
            </script>
        </div>
    </div>
</div>

<script src="../../static/js/jquery-3.6.0.min.js"></script>
<!--引入本地layui.js-->
<script src="../../static/layui/layui.js"></script>
<!--js-->
<script type="text/javascript">
    layui.config({
        base: '../../static/layui/layuiadmin/' //静态资源所在路径js
    }).extend({
        index: 'lib/index' //主入口模块
    }).use('index');
</script>

<script>

    layui.use(['element','form'], function(){
        var form = layui.form;
        var  layer = layui.layer;

        form.on('select(application_period)', function (data) {
          var type = $('#service_type').val();
          console.log(type);
            var period = data.value;
            console.log(period)

        });
    });


</script>



<form class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <script type="text/javascript">
        layui.use(['form'], function(){
            var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
            form.on('submit(LAY-user-front-submit)', function(data){
                $.ajax({
                    url : '/customer/addKeyWords',
                    type : 'post',
                    dataType : 'json',
                    data : data.field,
                    success : function (res) {

                        if(res.code == 200){
                            layer.msg(res.msg, {
                                offset: '15px'
                                ,icon: 1
                                ,time: 1000
                            },function () {
                                //刷新
                               window.location.reload();
                            });
                        }
                        if(res.code == 500){
                            layer.msg(res.msg, {
                                offset: '15px'
                                ,icon: 1
                                ,time: 1000
                            });
                        }
                    }
                })
            });

            $('#btn_search').click(function () {
                var cuscomerName=$('#customer_name').val();
                $.ajax({
                    url:'/keyWords/customerSearch',
                    type:'post',
                    data:{customer_name:cuscomerName},
                    dataType:'json',
                    success:function (res) {
                        if(res.code == 200){
                            layer.msg(res.msg, {
                                offset: '15px'
                                ,icon: 1
                                ,time: 1000
                            }/*,function () {
                                //刷新
                                console.log($('#customer_name0').val());

                                $('#customer_name').text($('#customer_name0').val());
                                console.log($('#customer_name').val())
                                form.render();
                            }*/);
                        }
                        if(res.code == 500){
                            layer.msg(res.msg, {
                                offset: '15px'
                                ,icon: 1
                                ,time: 1000
                            });
                        }
                    }
                })
            })


        });
//        layui.use(['form'], function(){
//            var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
//            $('#btn_search').click(function () {
//
//            var cuscomerName=$('#customer_name0').val();
//                $.ajax({
//                    url:"/keyWords/customerSearch",
//                    type:"post",
//                    data:{customer_name:cuscomerName},
//                    dataType:"json",
//                    success:function (res) {
//                        if(res.code == 200){
//                            layer.msg(res.msg, {
//                                offset: '15px'
//                                ,icon: 1
//                                ,time: 1000
//                            },function () {
//                                //刷新
//                                console.log($('#customer_name0').val());
//
//                                $('#customer_name').text($('#customer_name0').val());
//                                console.log($('#customer_name').val())
//                                form.render();
//                            });
//                        }
//                        if(res.code == 500){
//                            layer.msg(res.msg, {
//                                offset: '15px'
//                                ,icon: 1
//                                ,time: 1000
//                            },function () {
//                                //刷新
//                                window.location.reload();
//                            });
//                        }
//
//
//                    }
//                })
//
//
////           $('#customer_name').text(cuscomerName);
////           form.render();
//
//
//        })
//        })







    </script>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function(){
            var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate;

            //自定义验证规则
            form.verify({
                title: function(value){
                    if(value.length < 5){
                        return '标题至少得5个字符啊';
                    }
                }
                ,suanziId: [
                    /^[1-9]\d*$/
                    ,'只能是整数哦'
                ]
                ,pass: [
                    /^[\S]{6,12}$/
                    ,'密码必须6到12位，且不能出现空格'
                ]
                ,content: function(value){
                    layedit.sync(editIndex);
                }
            });




        });
    </script>


</form>


</body>
</html>

